package com.gzhryc.net_marketing.cloud.account.dao.db;

import com.gzhryc.common.NumberTools;
import com.gzhryc.jdbc.annotaion.Column;
import com.gzhryc.jdbc.annotaion.Id;
import com.gzhryc.jdbc.annotaion.Join;
import com.gzhryc.jdbc.annotaion.Table;
import com.gzhryc.pay.enums.TradeType;
import com.gzhryc.pay.models.IPayOrder;
import com.gzhryc.shared_device.base.enums.EPayType;
import com.gzhryc.net_marketing.cloud.account.dao.enums.CloudPayAccountDepositOrderEnum;

import java.util.Date;

/**
 * 云支付账号存款订单
 * @version 2022-07-04
 */
@Table(name="cloud_pay_account_deposit_order")
public class CloudPayAccountDepositOrder implements IPayOrder {

    private static final long serialVersionUID = 1L;

	@Id(auto = false)
    @Column(name="trade_no",note = "存款订单号")
    protected String tradeNo;

    @Column(length = 64,note="订单标题")
    protected String title;

    @Column(name = "account_id",notNull = true,note="云支付账号ID")
    protected Long accountId;

    @Column(name = "pay_type",notNull = true, note = "支付类型")
    protected Integer payType;

    @Column(name = "trade_type", notNull = true,note = "订单类型")
    protected String tradeType;

    @Column(name = "app_id", notNull = true,note = "收款APPID")
    protected String appId;

    @Column(name = "business_account", length = 64, note = "商户账号")
    protected String businessAccount;

    @Column(name = "external_trade_no", length = 64, note = "第三方支付订单编号")
    protected String externalTradeNo;

    /**
     * 微信：未支付前为预支付信息，预支付信息2小时过期
     */
    @Column(name = "external_content", type = "TEXT", note = "第三方支付订单内容")
    protected String externalContent;

    @Column(name = "notify_url", length = 255, note = "回调路径")
    protected String notifyUrl;

    @Column(name = "payer_id", length = 64, note = "第三方支付的用户ID")
    protected String payerId;

    @Column(name = "pay_money",notNull = true, note = "支付金额")
    protected Integer payMoney;

    @Column(name = "receipt_money",notNull = true,defVal = "0",note = "实收金额")
    protected Integer receiptMoney;

    @Column(notNull = true,defVal = "1",note="订单状态")
    protected Integer state;

    @Column(name = "pay_date", note = "支付时间")
    protected Date payDate;

    @Column(name = "update_date", note = "修改时间", autoUpdateTime = true)
    protected Date updateDate;

    @Column(name = "create_date", note = "创建时间")
    protected Date createDate;

    @Join(fromField="account_id")
    protected CloudPayAccount account;

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }

    public String getTitle() {
        return title;
    }

    @Override
    public String getNote() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Long getAccountId() {
        return accountId;
    }

    public void setAccountId(Long accountId) {
        this.accountId = accountId;
    }

    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    public String getTradeType() {
        return tradeType;
    }

    public void setTradeType(String tradeType) {
        this.tradeType = tradeType;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getBusinessAccount() {
        return businessAccount;
    }

    public void setBusinessAccount(String businessAccount) {
        this.businessAccount = businessAccount;
    }

    public String getExternalTradeNo() {
        return externalTradeNo;
    }

    public void setExternalTradeNo(String externalTradeNo) {
        this.externalTradeNo = externalTradeNo;
    }

    public String getExternalContent() {
        return externalContent;
    }

    public void setExternalContent(String externalContent) {
        this.externalContent = externalContent;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
    }

    public String getPayerId() {
        return payerId;
    }

    public void setPayerId(String payerId) {
        this.payerId = payerId;
    }

    public Integer getPayMoney() {
        return payMoney;
    }

    public void setPayMoney(Integer payMoney) {
        this.payMoney = payMoney;
    }

    public Integer getReceiptMoney() {
        return receiptMoney;
    }

    public void setReceiptMoney(Integer receiptMoney) {
        this.receiptMoney = receiptMoney;
    }

    public Date getPayDate() {
        return payDate;
    }

    public void setPayDate(Date payDate) {
        this.payDate = payDate;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public CloudPayAccount getAccount() {
        return account;
    }

    public void setAccount(CloudPayAccount account) {
        this.account = account;
    }

    public String getTradeTypeName(){
        TradeType tradeType = TradeType.valueOf(this.tradeType);
        if(tradeType != null){
            return tradeType.note();
        }
        return this.tradeType;
    }

    public String getStateName(){
        return CloudPayAccountDepositOrderEnum.State.note(this.state);
    }

    public String getPayTypeName(){
        return EPayType.note(this.payType);
    }

    public String getPayMoneyStr(){
        return NumberTools.getMoneyStr(this.payMoney);
    }

    public String getReceiptMoneyStr(){
        return NumberTools.getMoneyStr(this.receiptMoney);
    }
}
